/**
 * 确保同页面并发的接口请求，全部请求完毕，才会hide loading
 */
const startLoading = () => {
  document.getElementById('api-loading').style.display = 'block';
};

const endLoading = () => {
  document.getElementById('api-loading').style.display = 'none';
};
let loadingCount = 0
export const showLoading = () => {
  if (loadingCount === 0) {
    startLoading();
  }
  loadingCount++;
};

export const hideLoading = () => {
  if (loadingCount <= 0) {
    return;
  }
  loadingCount--;
  if (loadingCount === 0) {
    endLoading();
  }
};
